package com.gl.doc;

import com.gl.doc.builder.WordDocument;
import com.gl.doc.builder.WordDocumentBuilder;
import com.gl.doc.model.Paragraph;
import com.gl.doc.model.WordComment;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.List;

public class AppMain {
    public static void main(String[] args) throws FileNotFoundException {
        WordDocument wordDocument = WordDocumentBuilder.builderWordDocument(new FileInputStream(new File("D:\\data\\my_project\\word-operation\\src\\main\\resources\\A.docx")));
        List<Paragraph> paragraphs = wordDocument.getParagraphs();
        WordComment wordComment = new WordComment();
        wordComment.setAuthor("admin");
        wordComment.setContent("测试批注！");
        wordComment.setDate(new Date());
        wordComment.setTargetSentence("我是是测试文字，哈.哈哈。");
        wordComment.setTargetParagraph(paragraphs.get(0));
        wordDocument.addWordComment(wordComment);

        WordComment wordComment1 = new WordComment();
        wordComment1.setAuthor("test");
        wordComment1.setContent("测试批注！");
        wordComment1.setDate(new Date());
        wordComment1.setTargetSentence("我是是测试文字，哈哈");
        wordComment1.setTargetParagraph(paragraphs.get(1));
        wordDocument.addWordComment(wordComment1);

        wordComment1.setAuthor("zhangsan");
        wordComment1.setContent("测试批注！");
        wordComment1.setDate(new Date());
        wordComment1.setTargetSentence("哈");
        wordComment1.setTargetParagraph(paragraphs.get(1));
        wordDocument.addWordComment(wordComment1);

        wordComment1.setAuthor("test");
        wordComment1.setContent("测试批注！");
        wordComment1.setDate(new Date());
        wordComment1.setTargetSentence("我是是测试文字");
        wordComment1.setTargetParagraph(paragraphs.get(1));
        wordDocument.addWordComment(wordComment1);

        wordComment1.setAuthor("wangwu");
        wordComment1.setContent("测试批注！");
        wordComment1.setDate(new Date());
        wordComment1.setTargetSentence("哈哈哈，我是");
        wordComment1.setTargetParagraph(paragraphs.get(1));
        wordDocument.addWordComment(wordComment1);

        WordComment wordComment2 = new WordComment();
        wordComment2.setAuthor("admin");
        wordComment2.setContent("测试批注！");
        wordComment2.setDate(new Date());
        wordComment2.setTargetSentence("我是是测试文字，哈.哈哈。我是是测.试文字，哈哈哈");
        wordComment2.setTargetParagraph(paragraphs.get(0));
        wordDocument.addWordComment(wordComment2);
        wordDocument.save(new FileOutputStream(new File("xx.docx")));
    }
}
